package ai.people.core.security.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.http.HttpMethod;

import java.util.Objects;

/**
 * 忽略url
 *
 * @author yuanqinglong
 * @date 2022/4/17 10:12
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class IgnoreUrls {

    public IgnoreUrls(String[] methodAndUrl) {
        if (Objects.nonNull(methodAndUrl)) {
            if (methodAndUrl.length == 2) {
                httpMethod = HttpMethod.resolve(methodAndUrl[0].toUpperCase());
                url = methodAndUrl[1];
            } else {
                url = methodAndUrl[0];
            }
        }
    }

    /**
     * http方法
     */
    private HttpMethod httpMethod;

    /**
     * url
     */
    private String url;
}
